import { ReactNode } from "react";
import { CanvasContext, Context } from "./Context";
import { useSetState } from "../utils";

type Props = {
    children?: ReactNode;
  };
  
  export const CanvasProvider = ({ children }: Props) => {
      const [state, setState] = useSetState<Omit<CanvasContext, 'setState'>>({
          canvas: null, // fabric实例
          workspace: null, // 工作区实例
          frontImage: null, // 正面图片
          backImage: null, // 背面图片
          currentTab: 'front', // 当前选中的标签页：front | back
          currentImage: null, // 当前选中的图片
          currentToolBarTab: 'overview',
      });
  
      const value: CanvasContext = {
          ...state,
          setState,
      };
      return <Context.Provider value={value}>{children}</Context.Provider>;
  };
  